<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Linux进程管理深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        /* 首字下沉效果 */
        .drop-cap::first-letter {
            float: left;
            font-size: 4rem;
            line-height: 3rem;
            padding-right: 0.5rem;
            margin-top: 0.5rem;
            font-weight: 700;
            color: #4f46e5;
            font-family: 'Noto Serif SC', serif;
        }
        
        /* 代码块美化 */
        pre {
            background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
            border-radius: 12px;
            padding: 1.5rem;
            overflow-x: auto;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            position: relative;
        }
        
        pre::before {
            content: attr(data-language);
            position: absolute;
            top: 0.5rem;
            right: 1rem;
            font-size: 0.75rem;
            color: #94a3b8;
            text-transform: uppercase;
            letter-spacing: 0.1em;
        }
        
        code {
            color: #e2e8f0;
            font-family: 'Fira Code', monospace;
        }
        
        /* 表格美化 */
        table {
            border-collapse: separate;
            border-spacing: 0;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        }
        
        /* 卡片悬停效果 */
        .card-hover {
            transition: all 0.3s ease;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
        }
        
        /* 渐变文字 */
        .gradient-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        /* 动画效果 */
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animate-fadeInUp {
            animation: fadeInUp 0.8s ease-out;
        }
        
        /* 自定义滚动条 */
        ::-webkit-scrollbar {
            width: 10px;
        }
        
        ::-webkit-scrollbar-track {
            background: #f1f5f9;
        }
        
        ::-webkit-scrollbar-thumb {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <!-- Hero 区域 -->
    <section class="relative overflow-hidden bg-gradient-to-br from-indigo-600 via-purple-600 to-pink-500 text-white">
        <div class="absolute inset-0 bg-black opacity-20"></div>
        <div class="relative container mx-auto px-6 py-24 text-center">
            <h1 class="text-5xl md:text-7xl font-bold mb-6 animate-fadeInUp">
                Linux进程管理
                <span class="block text-3xl md:text-4xl mt-4 font-light">深度解析与实战指南</span>
            </h1>
            <p class="text-xl md:text-2xl mb-8 max-w-3xl mx-auto opacity-90 animate-fadeInUp" style="animation-delay: 0.2s;">
                从基础概念到高级技巧，掌握Linux系统的核心机制
            </p>
            <div class="flex justify-center space-x-8 animate-fadeInUp" style="animation-delay: 0.4s;">
                <div class="text-center">
                    <i class="fas fa-microchip text-4xl mb-2"></i>
                    <p class="text-sm">进程调度</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-exchange-alt text-4xl mb-2"></i>
                    <p class="text-sm">进程通信</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-signal text-4xl mb-2"></i>
                    <p class="text-sm">信号处理</p>
                </div>
            </div>
        </div>
        <div class="absolute bottom-0 left-0 right-0">
            <svg viewBox="0 0 1440 120" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M0 120L60 105C120 90 240 60 360 45C480 30 600 30 720 37.5C840 45 960 60 1080 67.5C1200 75 1320 75 1380 75L1440 75V120H1380C1320 120 1200 120 1080 120C960 120 840 120 720 120C600 120 480 120 360 120C240 120 120 120 60 120H0Z" fill="white"/>
            </svg>
        </div>
    </section>

    <!-- 主要内容区 -->
    <main class="container mx-auto px-6 py-12 max-w-6xl">
        
        <!-- 概念关系图 -->
        <section class="mb-16 bg-white rounded-2xl shadow-xl p-8 card-hover">
            <h2 class="text-3xl font-bold mb-6 text-center gradient-text">Linux进程管理核心概念</h2>
            <div class="mermaid text-center">
                graph TD
                    A[Linux进程管理] --> B[进程基础]
                    A --> C[进程调度]
                    A --> D[进程信号]
                    A --> E[进程间通信]
                    
                    B --> B1[PID进程标识]
                    B --> B2[内存空间]
                    B --> B3[文件描述符]
                    B --> B4[执行状态]
                    
                    C --> C1[CFS调度器]
                    C --> C2[优先级管理]
                    C --> C3[CPU亲和性]
                    
                    D --> D1[信号类型]
                    D --> D2[信号处理]
                    D --> D3[信号屏蔽]
                    
                    E --> E1[管道通信]
                    E --> E2[共享内存]
                    E --> E3[消息队列]
                    E --> E4[Socket通信]
                    
                    style A fill:#6366f1,stroke:#4f46e5,stroke-width:3px,color:#fff
                    style B fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#fff
                    style C fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#fff
                    style D fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#fff
                    style E fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#fff
            </div>
        </section>

        <!-- 第一章节 -->
        <article class="mb-16">
            <div class="bg-white rounded-2xl shadow-xl overflow-hidden card-hover">
                <div class="bg-gradient-to-r from-blue-500 to-purple-600 p-6">
                    <h2 class="text-3xl font-bold text-white flex items-center">
                        <i class="fas fa-cogs mr-4"></i>
                        一、进程：程序运行的基本单位
                    </h2>
                </div>
                <div class="p-8">
                    <p class="text-lg leading-relaxed mb-6 drop-cap text-gray-700">
                        每个在Linux系统中运行的程序都是一个进程。想象你同时打开浏览器、音乐播放器和代码编辑器，每个程序都对应一个或多个进程。我们可以通过<code class="bg-gray-100 px-2 py-1 rounded text-purple-600 font-mono">ps aux</code>命令查看当前所有进程：
                    </p>
                    
                    <pre data-language="bash" class="mb-6"><code>$ ps aux | grep firefox
user     1234  2.5  4.7 1234567 89012 ?      Sl   14:30   2:45 /usr/lib/firefox/firefox</code></pre>
                    
                    <div class="grid md:grid-cols-2 gap-6 mb-8">
                        <div class="bg-gradient-to-br from-blue-50 to-purple-50 p-6 rounded-xl">
                            <h3 class="text-xl font-semibold mb-4 text-purple-700">
                                <i class="fas fa-list-ul mr-2"></i>每个进程都拥有
                            </h3>
                            <ul class="space-y-3">
                                <li class="flex items-start">
                                    <i class="fas fa-fingerprint text-purple-500 mt-1 mr-3"></i>
                                    <span>唯一PID（进程ID）</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-memory text-purple-500 mt-1 mr-3"></i>
                                    <span>独立内存空间</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-file-alt text-purple-500 mt-1 mr-3"></i>
                                    <span>打开的文件描述符</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-play-circle text-purple-500 mt-1 mr-3"></i>
                                    <span>执行状态（运行/睡眠/停止等）</span>
                                </li>
                            </ul>
                        </div>
                        
                        <div class="bg-gradient-to-br from-pink-50 to-orange-50 p-6 rounded-xl">
                            <h3 class="text-xl font-semibold mb-4 text-orange-700">
                                <i class="fas fa-code mr-2"></i>实战案例1：创建子进程
                            </h3>
                            <p class="text-gray-600 mb-2">使用C语言的fork()系统调用创建子进程，理解进程创建的基本原理。</p>
                        </div>
                    </div>
                    
                    <pre data-language="c"><code>#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;

int main() {
    pid_t pid = fork();
    if (pid == 0) {
        printf("子进程PID: %d\n", getpid());
    } else {
        printf("父进程PID: %d，创建了子进程%d\n", getpid(), pid);
    }
    return 0;
}</code></pre>
                    
                    <div class="mt-6 p-4 bg-blue-50 rounded-lg border-l-4 border-blue-500">
                        <p class="text-gray-700">
                            <i class="fas fa-lightbulb text-blue-500 mr-2"></i>
                            编译执行后，你会看到父子进程的输出，这是理解进程创建的绝佳起点。
                        </p>
                    </div>
                </div>
            </div>
        </article>

        <!-- 第二章节 -->
        <article class="mb-16">
            <div class="bg-white rounded-2xl shadow-xl overflow-hidden card-hover">
                <div class="bg-gradient-to-r from-green-500 to-teal-600 p-6">
                    <h2 class="text-3xl font-bold text-white flex items-center">
                        <i class="fas fa-clock mr-4"></i>
                        二、进程调度：CPU时间分配的艺术
                    </h2>
                </div>
                <div class="p-8">
                    <p class="text-lg leading-relaxed mb-6 text-gray-700">
                        Linux采用CFS（完全公平调度器），其核心是红黑树数据结构。假设有三个进程A、B、C，它们的权重分别为1、2、3，CFS会按6:3:2的比例分配时间片。
                    </p>
                    
                    <div class="bg-gradient-to-r from-green-50 to-teal-50 p-6 rounded-xl mb-6">
                        <h3 class="text-xl font-semibold mb-4 text-teal-700">
                            <i class="fas fa-terminal mr-2"></i>常用调度命令
                        </h3>
                        <pre data-language="bash"><code>$ nice -n 5 ./cpu_intensive_task  # 设置优先级
$ chrt -f 99 ./real_time_task    # 设置实时调度策略</code></pre>
                    </div>
                    
                    <div class